const jwt=require("jsonwebtoken")
const key="hnhgbhghdbdjsuhdgts"
const whitelist=["/login","/register"]


function verifyToken(req,res,next){
    console.log(whitelist,req.url)
  if(whitelist.indexOf(req.url)!==-1){
    next()
  }
  else{
    jwt.verify(req.cookies.token,key,function(err,login){
        if(err){
            res.send({
                status:11110,
                msg:"token失效 请重新登录"
            })
            return
        }
        next()
       })
  }
}

module.export={
    verifyToken
}